#ifndef WIDGET_H
#define WIDGET_H

#include <QQueue>
#include <QTimer>
#include <QWidget>
QT_BEGIN_NAMESPACE
namespace Ui {
class Widget;
}
QT_END_NAMESPACE

/**
 * @brief 用API，实现tcp通信客户端
 */
class Widget : public QWidget {
  Q_OBJECT

public:
  Widget(QWidget *parent = nullptr);
  ~Widget();

  void onConnected();
  void onDisconnected();

private slots:
  void on_btnConnect_clicked();
  void on_btnSend_clicked();
  void onSendRead();

private:
  Ui::Widget *ui;
  int m_tcpsocket;
  bool m_connected = false;
  QQueue<QString> m_sendQueue;
  QTimer m_timer;
};
#endif // WIDGET_H
